home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmiSoft / Misc / emu / Wzonka-Lad.lha / Wzonka-Lad / src / prefs_to_cfg.s < prev    next >
Text File  |  1999-04-15  |  10KB  |  386 lines

  1.  
  2. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3. ;        .prefs to .cfg colour converter
  4. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5.  
  6.         incdir    "binworld:includes/"
  7.         include    "exec/memory.i"
  8.         include    "exec_lib.i"
  9.         include    "dos_lib.i"
  10.  
  11. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  12. ;        section converter,code
  13. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  14.  
  15. prefs_to_cfg:    movem.l    d2-d7/a2-a6,-(SP)        ;stack!
  16.         move.l    execbase,exec_base        ;cache it locally.
  17.  
  18.         move.l    a0,command_line
  19.  
  20.         move.l    exec_base,a6
  21.         lea    dos_name,a1
  22.         moveq.l    #39,d0
  23.         jsr    OpenLibrary(a6)
  24.         move.l    d0,dos_base
  25.         beq.w    quit
  26.  
  27. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  28. ;        allocate buffers
  29. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  30.  
  31.         move.l    exec_base,a6
  32.         move.l    #1024,d0
  33.         moveq.l    #MEMF_PUBLIC,d1            ;the system flags.
  34.         jsr    AllocVec(a6)
  35.         move.l    d0,cfg_file            ;the pointer here.
  36.         beq.w    quit
  37.  
  38.         move.l    #1024,d0
  39.         moveq.l    #MEMF_PUBLIC,d1            ;the system flags.
  40.         jsr    AllocVec(a6)
  41.         move.l    d0,prefs_file            ;the pointer here.
  42.         beq.w    quit
  43.  
  44.         move.l    #1024,d0
  45.         moveq.l    #MEMF_PUBLIC,d1            ;the system flags.
  46.         jsr    AllocVec(a6)
  47.         move.l    d0,in_name            ;the pointer here.
  48.         beq.w    quit
  49.  
  50.         move.l    #1024,d0
  51.         moveq.l    #MEMF_PUBLIC,d1            ;the system flags.
  52.         jsr    AllocVec(a6)
  53.         move.l    d0,out_name            ;the pointer here.
  54.         beq.w    quit
  55.  
  56. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  57. ;        locate and copy the input name
  58. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  59.  
  60.         move.l    command_line,a0
  61.         cmp.b    #$A,(a0)
  62.         beq.w    show_syntax            ;no inputs.
  63.  
  64.         move.l    in_name,a1
  65.         move.l    out_name,a2
  66.         moveq.l    #120-1,d0
  67. find_in_name:    move.b    (a0)+,d1
  68.         cmp.b    #'"',d1
  69.         beq.s    begin_found
  70.         dbra    d0,find_in_name
  71.         bra.w    error_in
  72.  
  73. begin_found:    moveq.l    #120-1,d0
  74. copy_in_name:    move.b    (a0)+,d1
  75.         cmp.b    #'"',d1
  76.         beq.s    end_in
  77.         move.b    d1,(a1)+
  78.         dbra    d0,copy_in_name
  79.         bra.w    error_in
  80.  
  81. end_in:        clr.b    (a1)                ;end of in name.
  82.  
  83. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  84. ;        locate and copy the output name
  85. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  86.  
  87.         addq.l    #1,a0                ;skip a " ".
  88.         moveq.l    #120-1,d0
  89. copy_out_name:    move.b    (a0)+,d1
  90.         cmp.b    #$A,d1
  91.         beq.s    end_out
  92.         move.b    d1,(a2)+
  93.         dbra    d0,copy_out_name
  94.         bra.w    error_out
  95.  
  96. end_out:    clr.b    (a2)                ;end of out name.
  97.  
  98. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  99. ;        read data from the .prefs file
  100. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  101.  
  102.         move.l    dos_base,a6            ;open the data file.
  103.         move.l    in_name,d1            ;the name of the file.
  104.         move.l    #Mode_Old,d2
  105.         jsr    Open(a6)            ;narsk.
  106.         move.l    d0,file_hd
  107.         beq.w    error_in_open            ;file error!
  108.  
  109.         move.l    d0,d1                ;file_hd.
  110.         move.l    prefs_file,d2            ;input address.
  111.         move.l    #3*4*2,d3            ;the length.
  112.         jsr    Read(a6)            ;read.
  113.  
  114.         move.l    file_hd,d1
  115.         jsr    Close(a6)            ;click.
  116.  
  117. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  118. ;        create the .cfg file
  119. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  120.  
  121.         move.l    cfg_file,a0
  122.         move.l    prefs_file,a1
  123.  
  124.         move.l    #"-bc0",(a0)+            ;background 0.
  125.         move.w    #" #",(a0)+
  126.         bsr.w    hex_to_ascii
  127.         move.b    #$A,(a0)+            ;enter.
  128.  
  129.         move.l    #"-bc1",(a0)+            ;background 1.
  130.         move.w    #" #",(a0)+
  131.         bsr.w    hex_to_ascii
  132.         move.b    #$A,(a0)+            ;enter.
  133.  
  134.         move.l    #"-bc2",(a0)+            ;background 2.
  135.         move.w    #" #",(a0)+
  136.         bsr.w    hex_to_ascii
  137.         move.b    #$A,(a0)+            ;enter.
  138.  
  139.         move.l    #"-bc3",(a0)+            ;background 3.
  140.         move.w    #" #",(a0)+
  141.         bsr.w    hex_to_ascii
  142.         move.b    #$A,(a0)+            ;enter.
  143.  
  144.         sub.l    #4*3,a1                ;bc -> wc.
  145.         move.l    #"-wc0",(a0)+            ;window 0.
  146.         move.w    #" #",(a0)+
  147.         bsr.w    hex_to_ascii
  148.         move.b    #$A,(a0)+            ;enter.
  149.  
  150.         move.l    #"-wc1",(a0)+            ;window 1.
  151.         move.w    #" #",(a0)+
  152.         bsr.w    hex_to_ascii
  153.         move.b    #$A,(a0)+            ;enter.
  154.  
  155.         move.l    #"-wc2",(a0)+            ;window 2.
  156.         move.w    #" #",(a0)+
  157.         bsr.w    hex_to_ascii
  158.         move.b    #$A,(a0)+            ;enter.
  159.  
  160.         move.l    #"-wc3",(a0)+            ;window 3.
  161.         move.w    #" #",(a0)+
  162.         bsr.w    hex_to_ascii
  163.         move.b    #$A,(a0)+            ;enter.
  164.  
  165.         move.l    #"-sc0",(a0)+            ;sprite 0.
  166.         move.w    #" #",(a0)+
  167.         bsr.w    hex_to_ascii
  168.         move.b    #$A,(a0)+            ;enter.
  169.  
  170.         move.l    #"-sc1",(a0)+            ;sprite 1.
  171.         move.w    #" #",(a0)+
  172.         bsr.w    hex_to_ascii
  173.         move.b    #$A,(a0)+            ;enter.
  174.  
  175.         move.l    #"-sc2",(a0)+            ;sprite 2.
  176.         move.w    #" #",(a0)+
  177.         bsr.w    hex_to_ascii
  178.         move.b    #$A,(a0)+            ;enter.
  179.  
  180.         move.l    #"-sc3",(a0)+            ;sprite 3.
  181.         move.w    #" #",(a0)+
  182.         bsr.w    hex_to_ascii
  183.         move.b    #$A,(a0)+            ;enter.
  184.  
  185.         sub.l    cfg_file,a0            ;a0 = the length.
  186.         move.l    a0,file_length
  187.  
  188. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  189. ;        save the .cfg file
  190. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  191.  
  192.         move.l    dos_base,a6            ;open the data file.
  193.         move.l    out_name,d1            ;the name of the file.
  194.         move.l    #Mode_New,d2
  195.         jsr    Open(a6)            ;narsk.
  196.         move.l    d0,file_hd
  197.         beq.w    error_in_save            ;file error!
  198.  
  199.         move.l    d0,d1                ;file_hd.
  200.         move.l    cfg_file,d2            ;input address.
  201.         move.l    file_length,d3            ;the length.
  202.         jsr    Write(a6)            ;write.
  203.  
  204.         move.l    file_hd,d1
  205.         jsr    Close(a6)            ;click.
  206.  
  207.         bsr.w    get_output
  208.         move.l    #ok_message,d2
  209.         move.l    #ok_message_end-ok_message,d3
  210.         bsr.w    print_message
  211.         bra.w    quit
  212.  
  213. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  214. ;        error messages
  215. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  216.  
  217. error_in_save:    bsr.w    get_output
  218.         move.l    #e_save,d2
  219.         move.l    #e_save_end-e_save,d3
  220.         bsr.w    print_message
  221.         bra.s    quit
  222.  
  223. error_in_open:    bsr.w    get_output
  224.         move.l    #e_open,d2
  225.         move.l    #e_open_end-e_open,d3
  226.         bsr.w    print_message
  227.         bra.s    quit
  228.  
  229. error_in:    bsr.w    get_output
  230.         move.l    #e_in_name,d2
  231.         move.l    #e_in_name_end-e_in_name,d3
  232.         bsr.w    print_message
  233.         bra.s    quit
  234.  
  235. error_out:    bsr.w    get_output
  236.         move.l    #e_out_name,d2
  237.         move.l    #e_out_name_end-e_out_name,d3
  238.         bsr.w    print_message
  239.         bra.s    quit
  240.  
  241. show_syntax:    bsr.w    get_output
  242.         move.l    #syntax_msg,d2
  243.         move.l    #syntax_msg_end-syntax_msg,d3
  244.         bsr.w    print_message
  245.  
  246. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  247. ;        quit
  248. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  249.  
  250. quit:        move.l    exec_base,a6
  251.         move.l    dos_base,d1
  252.         beq.s    no_dos
  253.         move.l    d1,a1
  254.         jsr    CloseLibrary(a6)
  255.  
  256. no_dos:        move.l    prefs_file,d0
  257.         beq.s    no_prefs
  258.         move.l    d0,a1
  259.         jsr    FreeVec(a6)
  260.  
  261. no_prefs:    move.l    cfg_file,d0
  262.         beq.s    no_cfg
  263.         move.l    d0,a1
  264.         jsr    FreeVec(a6)
  265.  
  266. no_cfg:        move.l    in_name,d0
  267.         beq.s    no_in_name
  268.         move.l    d0,a1
  269.         jsr    FreeVec(a6)
  270.  
  271. no_in_name:    move.l    out_name,d0
  272.         beq.s    no_out_name
  273.         move.l    d0,a1
  274.         jsr    FreeVec(a6)
  275.  
  276. no_out_name:    movem.l    (SP)+,d2-d7/a2-a6
  277.         moveq.l    #0,d0
  278.         rts
  279.  
  280. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  281. ;        convert a hex value to ascii letter
  282. ;        INPUT:
  283. ;        a0    = output (ascii).
  284. ;        a1    = input (hex).
  285. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  286.  
  287. hex_to_ascii:    moveq.l    #3-1,d2
  288. hex_to_ascii_I:    move.b    (a1)+,d0
  289.         move.b    d0,d1
  290.         lsr.b    #4,d1
  291.         cmp.b    #9,d1
  292.         ble.s    ascii_number_I
  293. ascii_letter_I:    sub.b    #$A,d1
  294.         add.b    #"A",d1
  295.         bra.s    hex_to_ascii_II
  296. ascii_number_I:    add.b    #"0",d1
  297.  
  298. hex_to_ascii_II:move.b    d1,(a0)+
  299.         and.b    #%1111,d0
  300.         cmp.b    #$9,d0
  301.         ble.s    ascii_number_II
  302. ascii_letter_II:sub.b    #$A,d0
  303.         add.b    #"A",d0
  304.         move.b    d0,(a0)+
  305.         dbra    d2,hex_to_ascii_I
  306.         rts
  307. ascii_number_II:add.b    #"0",d0
  308.         move.b    d0,(a0)+
  309.         dbra    d2,hex_to_ascii_I
  310.         rts
  311.  
  312. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  313. ;        get the output pointer / print an message
  314. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  315.  
  316. get_output:    move.l    dos_base,a6
  317.         jsr    Output(a6)
  318.         rts
  319.  
  320. print_message:    move.l    d0,d1
  321.         jsr    Write(a6)
  322.         rts
  323.  
  324. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  325. ;        section    stuff,data
  326. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  327.  
  328. exec_base:    dc.l    0
  329. dos_base:    dc.l    0
  330. dos_name:    dc.b    "dos.library",0
  331.         even
  332.  
  333. command_line:    dc.l    0
  334.  
  335. prefs_file:    dc.l    0
  336. cfg_file:    dc.l    0
  337.  
  338. in_name:    dc.l    0
  339. out_name:    dc.l    0
  340.  
  341. file_hd:    dc.l    0
  342. file_length:    dc.l    0
  343.  
  344. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  345. ;        error messages
  346. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  347.  
  348. e_save:        dc.b    "Unable to open the output file.",$A,0
  349. e_save_end:    even
  350.  
  351. e_open:        dc.b    "Unable to open the input file.",$A,0
  352. e_open_end:    even
  353.  
  354. e_in_name:    dc.b    "Error in input name.",$A,0
  355. e_in_name_end:    even
  356.  
  357. e_out_name:    dc.b    "Error in output name.",$A,0
  358. e_out_name_end:    even
  359.  
  360. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  361. ;        no conversion errors message
  362. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  363.  
  364. ok_message:    dc.b    "No errors.",$A,0
  365. ok_message_end:    even
  366.  
  367. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  368. ;        the syntax message
  369. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  370.  
  371. syntax_msg:    dc.b    $A
  372.         dc.b    "       Wzonka-Lad .prefs to VGB .cfg file converter v1.01",$A
  373.         dc.b    "             Copyright 1997 Ville Helin (30-May-97)",$A,$A
  374.         dc.b    'SYNTAX: prefs_to_cfg "[INPUT NAME (.PREFS)]" [OUTPUT NAME (.CFG)]',$A,$A
  375.         dc.b    0
  376. syntax_msg_end:    even
  377.  
  378. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  379. ;        the version string
  380. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  381.  
  382. version_string:    dc.b    "$VER: .prefs to .cfg converter 1.01 (30.05.97)",0
  383.         even
  384.  
  385.         END
  386.